import 'package:flutter/material.dart';
import 'package:flutter_menu/app_config.dart';
import 'package:flutter_menu/biz/order/order_pg.dart';
import 'package:flutter_menu/data/base_provider.dart';
import 'package:flutter_menu/model/formula_model.dart';
import 'package:flutter_menu/model/material_model.dart';
import 'package:flutter_menu/model/menu_model.dart';
import 'package:flutter_menu/model/product_model.dart';
import 'package:flutter_menu/objectbox.g.dart';

class MaterialDeptStockProvider extends BaseProvider<MaterialDeptStockModel> {
  MaterialDeptStockProvider(super.store);

  MaterialDeptStockModel? getStockInfo(String materialId, String deptId) {
    return box
        .query(MaterialDeptStockModel_.materialId.equals(materialId) &
            MaterialDeptStockModel_.deptId.equals(deptId))
        .build()
        .findFirst();
  }

  double getQuantityInStock(String materialId, String deptId) {
    return box
            .query(MaterialDeptStockModel_.materialId.equals(materialId) &
                MaterialDeptStockModel_.deptId.equals(deptId))
            .build()
            .findFirst()
            ?.stockQuantity ??
        0.0;
  }
}
